package com.zq.zhufengfm.tasks.albumDetail;

import com.zq.zhufengfm.Constants;
import com.zq.zhufengfm.client.ClientApi;
import com.zq.zhufengfm.tasks.BaseTask;
import com.zq.zhufengfm.tasks.TaskCallback;
import com.zq.zhufengfm.tasks.TasklResult;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Project_name : ZhuFengFM
 * Author : zhaoQiang
 * Date : 2015/10/24,10:51
 * Email : zhaoq_hero@163.com
 */
public class AlbumDetailTask extends BaseTask {

    public AlbumDetailTask(TaskCallback taskCallback) {
        super(taskCallback);
    }

    @Override
    protected TasklResult doInBackground(String... params) {
        TasklResult ret = new TasklResult();// params 为数据Id

        //添加异步任务唯一标识：
        ret.action = Constants.TASK_ACTION_ALBUMDETAIL;

//        调用  Client中getAlbumDetail方法： 获取JSONObject:
        JSONObject jsonObject = ClientApi.getAlbumDetail(params[0]);

        //返回数据  返回数据
        if(jsonObject != null){
            //判断返回数据：
            try {
                ret.resultCode = jsonObject.getInt("ret");
                //数据返回：
                ret.data = jsonObject;
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
        return ret;
    }
}
